home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Misc / GMS / GMSDev / Source / C / Raster / ColourBars.c next >
Encoding:
C/C++ Source or Header  |  1997-12-23  |  3.6 KB  |  114 lines

  1. /* Dice: dcc -l0 -mD dpk.o ColourBars.c -o ColourBars
  2. **
  3. ** Colourlists are those nice colour gradients used in demos and games,
  4. ** usually  sitting in the background of your screen.  You can use them to
  5. ** get more colours on screen than what is really available.  Be warned that
  6. ** many graphics cards do not support this feature and will not display
  7. ** anything.
  8. ** 
  9. ** You can move the green colour bar by moving the mouse up and down.  Pressing
  10. ** the right mouse button tests the Hide() and Display() actions.  Press the
  11. ** left mouse button to exit the demo.
  12. */
  13.  
  14. #include <proto/dpkernel.h>
  15.  
  16. BYTE *ProgName      = "Colour Bars";
  17. BYTE *ProgAuthor    = "Paul Manias";
  18. BYTE *ProgDate      = "16 December 1997";
  19. BYTE *ProgCopyright = "DreamWorld Productions (c) 1996-1997.  Freely distributable.";
  20. BYTE *ProgShort     = "Raster demonstration.";
  21.  
  22. LONG ColourBar1[] = {
  23.   0x100000,0x200000,0x300000,0x400000,0x500000,0x600000,0x700000,0x800000,0x900000,0xa00000,
  24.   0xb00000,0xc00000,0xd00000,0xe00000,0xe00000,0xe00000,0xd00000,0xc00000,0xb00000,0xa00000,
  25.   0x900000,0x800000,0x700000,0x600000,0x500000,0x400000,0x300000,0x200000,0x100000,0x000000,
  26.   -1
  27. };
  28.  
  29. LONG ColourBar2[] = {
  30.   0x001000,0x002000,0x003000,0x004000,0x005000,0x006000,0x007000,0x008000,0x009000,0x00a000,
  31.   0x00b000,0x00c000,0x00d000,0x00e000,0x00f000,0x00e000,0x00d000,0x00c000,0x00b000,0x00a000,
  32.   0x009000,0x008000,0x007000,0x006000,0x005000,0x004000,0x003000,0x002000,0x001000,0x000000,
  33.   -1
  34. };
  35.  
  36. LONG ColourBar3[] = {
  37.   0x000010,0x000020,0x000030,0x000040,0x000050,0x000060,0x000070,0x000080,0x000090,0x0000a0,
  38.   0x0000b0,0x0000c0,0x0000d0,0x0000e0,0x0000f0,0x0000e0,0x0000d0,0x0000c0,0x0000b0,0x0000a0,
  39.   0x000090,0x000080,0x000070,0x000060,0x000050,0x000040,0x000030,0x000020,0x000010,0x000000,
  40.   -1
  41. };
  42.  
  43. struct RColourList RColourList1;
  44. struct RColourList RColourList2;
  45. struct RColourList RColourList3;
  46.  
  47. struct RColourList RColourList1 = {
  48.   ID_RASTCOLOURLIST, 1, NULL, NULL, (struct RHead *)&RColourList2,
  49.   000,3,0,ColourBar1
  50. };
  51.  
  52. struct RColourList RColourList2 = {
  53.   ID_RASTCOLOURLIST, 1, NULL, (struct RHead *)&RColourList1, (struct RHead *)&RColourList3,
  54.   100,1,0,ColourBar2
  55. };
  56.  
  57. struct RColourList RColourList3 = {
  58.   ID_RASTCOLOURLIST, 1, NULL, (struct RHead *)&RColourList2, NULL,
  59.   170,1,0,ColourBar3
  60. };
  61.  
  62. /***************************************************************************/
  63.  
  64. void main(void)
  65. {
  66.    struct GScreen *Screen;
  67.    struct Raster  *Raster;
  68.    struct JoyData *JoyData;
  69.    WORD   tick = NULL;
  70.  
  71.    if (Raster = Get(ID_RASTER)) {
  72.  
  73.       Raster->Command = (struct RHead *)&RColourList1;
  74.       Raster->Command->Prev = (struct RHead *)Raster;
  75.  
  76.       if (Screen = InitTags(NULL,
  77.           TAGS_SCREEN, NULL,
  78.           GSA_Raster,  Raster,
  79.           GSA_Attrib,  BLKBDR,
  80.           TAGEND)) {
  81.  
  82.          Display(Screen);
  83.  
  84.          if (JoyData = Init(Get(ID_JOYDATA),NULL)) {
  85.             do {
  86.                Query(JoyData);
  87.                RColourList2.YCoord += JoyData->YChange;
  88.                if (RColourList2.YCoord < 0)   RColourList2.YCoord = 0;
  89.                if (RColourList2.YCoord > 226) RColourList2.YCoord = 226;
  90.                Activate(Raster);
  91.                WaitAVBL();
  92.  
  93.                if ((JoyData->Buttons & JD_RMB) AND (tick IS NULL)) {
  94.                   if (Raster->Flags & RSF_DISPLAYED) {
  95.                      Hide(Raster);
  96.                   }
  97.                   else {
  98.                      Display(Raster);
  99.                   }
  100.                   tick = 25;
  101.                }
  102.  
  103.                if (tick) tick--;
  104.  
  105.             } while (!(JoyData->Buttons & JD_LMB));
  106.          Free(JoyData);
  107.          }
  108.       Free(Screen);
  109.       }
  110.    Free(Raster);
  111.    }
  112. }
  113.  
  114.